package com.cat.dataStructure;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/removing-stars-from-a-string/description/
 * @create 2025/9/4 23:44
 * @since JDK17
 */

public class Solution55 {
    public String removeStars(String s) {
        int n = s.length(), top = 0;
        char[] ans = new char[n];
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) != '*') {
                ans[top++] = s.charAt(i);
            } else {
                top--;
            }
        }

        return String.valueOf(ans, 0, top);
    }
}
